package com.coffee.websocket.command;


import com.coffee.websocket.SessionManager;
import com.coffee.websocket.MochaWebsocketResponse;
import com.coffee.websocket.metadata.MochaBasicBinaryMessage;
import com.coffee.websocket.metadata.MochaBinaryProtocol;
import lombok.Getter;
import lombok.Setter;

import javax.websocket.Session;
import java.nio.ByteBuffer;
import java.util.List;

/**
 * 用于 handler 需要的信息
 * @author: songkui
 * @since: 2023/2/21 18:05
 */
@Getter
@Setter
public class MochaBasicParam {
    private Session session;


    public void sendByteBuffer(ByteBuffer data) {
        SessionManager.sendByteBuffer(this.session, data);
    }

    public void sendByteBuffer(Long userId, ByteBuffer data) {
        SessionManager.sendByteBuffer(userId, data);
    }

    public void sendText(String message) {
        SessionManager.sendText(this.session, message);
    }

    public <T> void sendMessage(MochaWebsocketResponse<T> mochaResponse) {
        SessionManager.sendMessage(this.session, mochaResponse);
    }

    public <T> void sendMessage(Long userId, MochaWebsocketResponse<T> mochaResponse) {
        SessionManager.sendMessage(userId, mochaResponse);
    }

    public <T> void sendMessage(List<Long> idList, MochaWebsocketResponse<T> mochaResponse) {
        SessionManager.sendMessage(idList, mochaResponse);
    }

    public <T> void sendMessageByAll(MochaWebsocketResponse<T> mochaResponse) {
        SessionManager.sendMessageByAll(mochaResponse);
    }


    //--------------Binary-message--------------

    public <T extends MochaBasicBinaryMessage> void sendMessage(MochaBinaryProtocol<T> binaryMessage) {
        SessionManager.sendMessage(this.session, binaryMessage);
    }

    public <T extends MochaBasicBinaryMessage> void sendMessage(Long userId, MochaBinaryProtocol<T> binaryMessage) {
        SessionManager.sendMessage(userId, binaryMessage);
    }

    public <T extends MochaBasicBinaryMessage> void sendMessage(List<Long> idList, MochaBinaryProtocol<T> binaryMessage) {
        SessionManager.sendMessage(idList, binaryMessage);
    }

    public <T extends MochaBasicBinaryMessage> void sendMessageByAll(MochaBinaryProtocol<T> binaryMessage) {
        SessionManager.sendMessageByAll(binaryMessage);
    }


}
